<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script>
			function fun(){
				var age = document.getElementById("age").value;
				if (isNaN(age)) {
					alert("输入的年龄必须为数字!");
				} else{
					if (age<=0) {
						alert("年龄不能为负数!");
					} else{
						if (age<18) {
							alert("你未成年!");
						} else{
							alert("你已经成年!");
						}
					}
					
				}
			}
		</script>
	</head>
	<body>
		请输入年龄:<input type="text" id="age"/>
		<button onclick="fun()">查询</button>
	</body>
</html>
